package 替换空格;

/**
 * @author zhengTao
 * @version 1.0
 * @description: 剑指offer05,也可以用双指针
 * @date 2022/10/22 9:46
 */
public class ToOffer05 {
    public String replaceSpace(String s) {
         StringBuilder newStr =new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i)==' '){
                newStr.append("%20");
            }else {
                newStr.append(s.charAt(i));
            }
        }
        return newStr.toString();
    }
}
